import type { CardDetail, CardListData, CardListParams, CardParams, CarListData, CarListParams, getRoleDetail, GetRoleDetailData } from "@/types/card"
import type { RoleParams } from "@/types/system"
import { request } from "@/utils/reuqest"

/**
 * 查看月卡信息列表
 * @param params 
 * @returns 
 */
export const getCardListAPI = (params: CardListParams) => {
  return request<CardListData>('/parking/card/list', 'GET', params)
}

/**
 * 新增月卡
 * @param params 
 * @returns 
 */
export const createCardAPI = (params: Partial<CardParams>) => {
  return request('/parking/card', 'POST', params)
}

/**
 * 获取编辑页月卡详情
 * @param id 月卡id
 * @returns 
 */
export const getCardDetailAPI = (id: string) => {
  return request<CardDetail>(`/parking/card/detail/${id}`)
}

/**
 * 编辑月卡
 * @param {*} data
 * @returns
 */
export const updateCardAPI = (data: Partial<CardDetail>) => {
  return request('/parking/card/edit', 'PUT', data)
}

/**
 * 删除月卡
 * @param ids 
 * @returns 
 */
export const delCardAPI = (ids: number[]) => {
  // 批量删除时，id用逗号隔开，通过 join 方法拼接字符串
  return request(`/parking/card/${ids.join(',')}`, 'DELETE')
}

/**
 * 获取规则列表
 * @param { page, pageSize} params
 * @returns
 */
export const getRuleListAPI = (params: CarListParams) => {
  return request<CarListData>('parking/rule/list', 'GET', params)
}
export const createRuleAPI = (params: RoleParams) => {
  return request('/park/sys/role', 'POST', params)
}

/**
 * 查询当前角色详情-权限和分配人数
 * @Header /park/sys/role/{roleId}
 * @returns
 */
export const getRoleDetailAPI=(roleId:string)=>{
  return request(`park/sys/role/${roleId}`)
}

/**
 * 系统管理-角色管理-修改角色
 * @param {*} data
 * @returns
 */
export const updateRoleAPI=(data:RoleParams)=>{
  return request(`/park/sys/role`,'PUT',data)
}
export const deleRoleAPI=(id:string)=>{
  return request(`park/sys/role/${id}`,'DELETE')
}